package com.suxin.thread;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author Tang
 * @classname ThreadTest
 * @description [  ]
 * @date 2021/4/6 20:43
 */
public class LockSupportTest {

    public static void main(String[] args) throws Exception{

        Thread thread0 = new Thread(() -> {
            System.out.println("park之前...");
            LockSupport.park(); // interrupt 不会唤醒
            LockSupport.park(Thread.currentThread()); //interrupt 会唤醒
            System.out.println("中断唤醒..." + Thread.interrupted());
        });
        thread0.start();

        TimeUnit.SECONDS.sleep(2);
        thread0.interrupt();
        TimeUnit.SECONDS.sleep(2);

//        System.out.println("开始唤醒Thread0....");
//        LockSupport.unpark(thread0);
//        TimeUnit.SECONDS.sleep(5);
    }

}